unit ufrmmain;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ActnList,
  Menus, ComCtrls, ExtCtrls, StdCtrls, ExpandPanels, uApplicationdata;

type

  { TfrmMain }

  TfrmMain = class(TForm)
    actExit: TAction;
    actAbout: TAction;
    actFillTopics: TAction;
    AL: TActionList;
    Button1: TButton;
    MM: TMainMenu;
    miExit: TMenuItem;
    MenuItem2: TMenuItem;
    miAbout: TMenuItem;
    miFiles: TMenuItem;
    MyRollOut1: TMyRollOut;
    mrInitDatabase: TMyRollOut;
    PC: TPageControl;
    pnlLeft: TPanel;
    StatusBar1: TStatusBar;
    procedure actExitExecute(Sender: TObject);
    procedure actFillTopicsExecute(Sender: TObject);
    procedure ALExecute(AAction: TBasicAction; var Handled: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
    _ApplicationData: TApplicationData;
    function InitDatabaseConnections: boolean;

  public
    { public declarations }
  end; 

var
  frmMain: TfrmMain;

implementation

{$R *.lfm}

uses udmGeneral, udmTopics, udmManageDatabase;

{ TfrmMain }

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------

procedure TfrmMain.actExitExecute(Sender: TObject);
begin
  self.Release;
end;

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------

procedure TfrmMain.actFillTopicsExecute(Sender: TObject);
begin
     dmManageDatabase.initTopics;
end;

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------

procedure TfrmMain.ALExecute(AAction: TBasicAction; var Handled: Boolean);
begin

end;

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------

procedure TfrmMain.FormCreate(Sender: TObject);
begin
  _ApplicationData := TApplicationData.Create(self);
  if not InitDataBaseConnections then release;
end;

//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------

function TfrmMain.InitDatabaseConnections: boolean;
begin
     try
        dmGeneral := tdmGeneral.create(self, _ApplicationData);
        dmGeneral.Connect;
        dmTopics := tdmTopics.create(self, _ApplicationData);
        result := true;
     finally
      // FreeStatement
     end;
end;

end.

